<template>
  <div class="NewsManage">
    <el-breadcrumb separator="/">
      <el-breadcrumb-item>门户管理</el-breadcrumb-item>
      <el-breadcrumb-item><a>新闻管理</a></el-breadcrumb-item>
    </el-breadcrumb>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="全部新闻" name="allNews">
        <public-model-index mode="allNews" />
      </el-tab-pane>
      <el-tab-pane label="轮播图" name="rotationChart">
        <public-model-index mode="rotationChart" />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
  
<script>
import PublicModelIndex from "./PublicModelIndex.vue";
export default {
  name: "NewsManage",
  components: { PublicModelIndex },
  data() {
    return {
      activeName: "allNews",
    };
  },
  mounted() {
    let tab = this.$route.query.tab;
    tab
      ? (this.activeName = tab)
      : (window.location.href =
          window.location.origin +
          "/#/systemtools/portaladmin/NewsManage?tab=allNews");
  },
  methods: {
    handleClick(target) {
      if (target.index === '1') {
        window.location.href =
          window.location.origin +
          "/#/systemtools/portaladmin/NewsManage?tab=rotationChart";
      } else {
        window.location.href =
          window.location.origin +
          "/#/systemtools/portaladmin/NewsManage?tab=allNews";
      }
    },
  },
};
</script>